﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Willson.JsbManager.Comm;
using Willson.JsbManager.Bll;
using Willson.JsbManager.BllEntity;

namespace Willson.JsbManager.UI
{
    public partial class BaseForm : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        protected WinInfo info = null;
        protected Boolean quick = false;
        
        public BaseForm()
        {
            InitializeComponent();
           
        }

        public void InitWinInfo(WinInfo info)
        {
            this.info = info;

            QueryMenuQuickFlag();

            if (quick)
                this.button_quick.Text = "移除快捷方式";
            else
                this.button_quick.Text = "添加快捷方式";

            this.FunctionName.Text = GlobalClass.GetMenuItemName(info.Menu_id);
            this.Text = GlobalClass.GetFormCaptionText(info.Menu_id);
        }

        private void QueryMenuQuickFlag()
        {
            quick = BLLFactory<BLLMenuInfo>.Instance.QueryMenuQuickFlag(this.info.User_id, this.info.Menu_id);
        }

        /// <summary>
        /// 通用设置快捷方式
        /// </summary>
        protected void MakeQuickFlag()
        {
            BLLFactory<BLLMenuInfo>.Instance.MakeQuickFlag(this.info.User_id, this.info.Menu_id, Convert.ToInt32(!quick));
            QueryMenuQuickFlag();

            MainForm main = Program.context.MainForm as MainForm;
            main.ResetQuickMenuList();
        }

        /// <summary>
        /// 通用选择年月信息函数
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        public virtual void SelectYearMonth(int year,int month)
        {
        }

        /// <summary>
        /// 通用选择年月信息函数
        /// </summary>
        /// <param name="year"></param>
        /// <param name="jd"></param>
        public virtual void SelectYearJD(int year, int jd)
        {
        }

        /// <summary>
        /// 通用用户单位查询函数
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        public virtual void SelectCompanyId(int id)
        {
        }

        private void button_quick_Click(object sender, EventArgs e)
        {
            MakeQuickFlag();

            if (quick)
                this.button_quick.Text = "移除快捷方式";
            else
                this.button_quick.Text = "添加快捷方式";
        }
    }
}
